package main

import (
	"net/http"

	_ "ezgin-example/docs"
	"ezgin-example/i18n"
	"ezgin-example/router"

	"github.com/gin-gonic/gin"
	"github.com/loebfly/ezgin"
	"github.com/loebfly/ezgin/app"

	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

//@title	{swag-title}
//@version 	{swag-version}
//@description	{swag-description}
func main() {

	// 初始化ezgin
	ezgin.Start(app.Start{
		GinCfg: app.GinCfg{
			RecoveryHandler: func(c *gin.Context, err interface{}) {
				c.JSON(http.StatusOK, i18n.SystemError.ErrorRes())
			},
			NoRouteHandler: func(c *gin.Context) {
				c.JSON(http.StatusOK, i18n.UrlNotFound.ErrorRes())
			},
			SwaggerRelativePath: "/docs/*any",
			SwaggerHandler:      ginSwagger.WrapHandler(swaggerFiles.Handler),
		},
	})

	// 配置路由
	router.Setup()

	// 等待退出信号
	ezgin.ShutdownWhenExitSignal()
}
